<%--
  Created by IntelliJ IDEA.
  User: HP
  Date: 2021/9/10
  Time: 21:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>申请挂号</title>

    <meta name="content-type" content="text/html; charset=UTF-8">

    <link rel="stylesheet" type="text/css" href="css/register.css">

    <script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" >


        var departmentName = [{label:"eye",value:"内科"},{label:"ear",value:"外科"},{label:"head",value:"精神病科"}];
        //var school ={"计算机学院","自动化学院","机械学院"};
        var eyeDep = new Array("萧炎","唐三","叶凡","石昊");
        var earDep = new Array("狠人大帝","徐凤年","秦羽","云撤");
        var headDep = new Array("沈祺尧","胡景潇","刘诗祥");

        function initDep(){
            var department=document.getElementById("department");
            var i =0;
            var s ="";
            for(i=0;i<departmentName.length;i++){
                s += "<option value="+departmentName[i].label +">"+departmentName[i].value+"</option>";
            }
            department.innerHTML=s;

            var doctor=document.getElementById("doctor");
            i =0;
            s ="";
            for(i=0;i<eyeDep.length;i++){
                s += "<option>"+eyeDep[i]+"</option>";
                //   var op=document.createElement("option");
                //   op.setAttribute("label", s.label);
                //   op.setAttribute("value", s.value);
                //   department.appendChild(op);
            }
            doctor.innerHTML=s;
        }

        function changeDoctor(){
            var department =document.getElementById("department");
            var t=department.value;
            var s ="";
            var i = 0;
            switch(t){
                case "eye":
                    for(i=0;i<eyeDep.length;i++){
                        s += "<option>"+eyeDep[i]+"</option>";
                    }
                    break;
                case "ear":
                    for(i=0;i<earDep.length;i++){
                        s += "<option>"+earDep[i]+"</option>";
                    }
                    break;
                case "head":
                    for(i=0;i<headDep.length;i++){
                        s += "<option>"+headDep[i]+"</option>";
                    }
                    break;
            }

            var doctor=document.getElementById("doctor");
            doctor.innerHTML=s;

        }

        function myFunction(){
            alert("提交成功！");
        }

    </script>


</head>
<body onload="initDep()">
<br>
<br>

<h2 style="margin-left: 15%">申请挂号</h2>
<br>

<hr align=center width="70%" SIZE=3>
<br>
<br>
<center>
    <form action="patientServlet">
        <table>
            <tr><input type = "hidden" name = "operation" value="commit"></tr>
            <tr> <td> 科室：</td>
                <td style="width: 300px">
                    <label class="label1">
                    <select name = "department" id ="department" onchange = "changeDoctor()" class="input1">

                    </select>
                    </label>
                </td>
            </tr>
            <tr><td>&nbsp;</td></tr>
            <tr> <td> 医生：</td>
                <td style="width: 300px">
                    <label class="label1">
                    <select name = "doctor" id="doctor"  class="input1">

                    </select>
                    </label>
                </td>
            </tr>
        </table>

        <input  type = "submit" value = "确定" class="sub" onclick="myFunction()">&nbsp;&nbsp;&nbsp;&nbsp;
        <a href="patientServlet?operation=homePage"><input type="button" value="返回"  class="sub"></a>
    </form>
</center>


</body>
</html>
